package com.ruoyi.project.basic.districtclass.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.basic.districtclass.domain.JcDistrictclass;
import com.ruoyi.project.basic.districtclass.service.IJcDistrictclassService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 地区分类Controller
 * 
 * @author frank
 * @date 2024-08-24
 */
@RestController
@RequestMapping("/basic/districtclass/districtclass")
public class JcDistrictclassController extends BaseController
{
    @Autowired
    private IJcDistrictclassService jcDistrictclassService;

    /**
     * 查询地区分类列表
     */
    @PreAuthorize("@ss.hasPermi('basic/districtclass:districtclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcDistrictclass jcDistrictclass)
    {
        startPage();
        List<JcDistrictclass> list = jcDistrictclassService.selectJcDistrictclassList(jcDistrictclass);
        return getDataTable(list);
    }

    /**
     * 导出地区分类列表
     */
    @PreAuthorize("@ss.hasPermi('basic/districtclass:districtclass:export')")
    @Log(title = "地区分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcDistrictclass jcDistrictclass)
    {
        List<JcDistrictclass> list = jcDistrictclassService.selectJcDistrictclassList(jcDistrictclass);
        ExcelUtil<JcDistrictclass> util = new ExcelUtil<JcDistrictclass>(JcDistrictclass.class);
        util.exportExcel(response, list, "地区分类数据");
    }

    /**
     * 获取地区分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic/districtclass:districtclass:query')")
    @GetMapping(value = "/{jcDistrictclassoid}")
    public AjaxResult getInfo(@PathVariable("jcDistrictclassoid") String jcDistrictclassoid)
    {
        return success(jcDistrictclassService.selectJcDistrictclassByJcDistrictclassoid(jcDistrictclassoid));
    }

    /**
     * 新增地区分类
     */
    @PreAuthorize("@ss.hasPermi('basic/districtclass:districtclass:add')")
    @Log(title = "地区分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcDistrictclass jcDistrictclass)
    {
        return toAjax(jcDistrictclassService.insertJcDistrictclass(jcDistrictclass));
    }

    /**
     * 修改地区分类
     */
    @PreAuthorize("@ss.hasPermi('basic/districtclass:districtclass:edit')")
    @Log(title = "地区分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcDistrictclass jcDistrictclass)
    {
        return toAjax(jcDistrictclassService.updateJcDistrictclass(jcDistrictclass));
    }

    /**
     * 删除地区分类
     */
    @PreAuthorize("@ss.hasPermi('basic/districtclass:districtclass:remove')")
    @Log(title = "地区分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jcDistrictclassoids}")
    public AjaxResult remove(@PathVariable String[] jcDistrictclassoids)
    {
        return toAjax(jcDistrictclassService.deleteJcDistrictclassByJcDistrictclassoids(jcDistrictclassoids));
    }
}
